<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<script type="text/javascript">
    Date.prototype.Format = function (fmt) { //author: meizz
        var o = {
            "M+": this.getMonth() + 1, //月份
            "d+": this.getDate(), //日
            "h+": this.getHours(), //小时
            "m+": this.getMinutes(), //分
            "s+": this.getSeconds(), //秒
            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
            "S": this.getMilliseconds() //毫秒
        };
        if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
        for (var k in o)
            if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
        return fmt;
    }

        function setIdNo(){
            getBaseinfo('idNo','age');
            getBirthday('idNo','birthdayDate')
        }

    $(function(){
        setIdNo();
        var date = new Date().Format("yyyy-MM-dd");
        $("#hospitalizedDate").val(date);
        $("#attackdate").val(date);
    })
    function isNoFuChanKe(hiddenVal){
        var sex=$("input[name='sex']").val();
        var age=$("#age").val();
        //妇产科科室Id
        var fuChanKeId="5df811a288ad4871ba5fc1a598d9a4b4";
        if(hiddenVal==fuChanKeId){
            if(sex!='1'){
                toastr.error("性别不符合科室要求，请重新选择！");
                layer.reload();
            }
            if(age<='14' || age>='50'){
                toastr.error("年龄不符合科室要求，请重新选择！");
                layer.reload();
            }
            else{
                layer.close();
            }
        }
    }
    function isNoDischargeDate(){
        var dischargeDate=$("#dischargeDate").val();
        if(dischargeDate==null || dischargeDate==''){
            $("#submit").attr("type","submit");
        }
        else{
            toastr.error("病人还未出院，不能进行入院操作！");
        }
    }

    function printLive(clinicId){
        printPdf('${ctx}/doctor/liveRequisition/printLive', 'clinicId='+clinicId);
    }
</script>
<div class="panel-body">
    <div class="table-responsive no-border">
        <form id="inputForm"   method="post" class="form-horizontal" onsubmit="return formSaveLoad('rigthDoctorCenterDiv','inputForm','${ctx}/doctor/liveRequisition/save','${ctx}/doctor/liveRequisition/index?clinicId=${clinicMaster.id}');">
            <input type="hidden" name="id" value="${liveRequisition.id}" >
            <input type="hidden" name="clinicId" value="${clinicMaster.id}" >
            <div class="col-lg-11">
                <div class="opertion_items">
                    <div>基本信息</div>
                </div>
                <fieldset>
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-5 control-label">姓名：</label>
                            <div class="col-sm-7">
                                <label class="usual_label">${clinicMaster.name}</label>
                                <input type="hidden" name="name" value="${clinicMaster.name}" >
                                <input type="hidden" name="patMasterIndex.id" value="${clinicMaster.patMasterIndex.id}" >
                                <input type="hidden" name="inputCode" value="${clinicMaster.inputCode}" >
                                <input type="hidden" name="chargeType" value="${clinicMaster.chargeType}" >
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">出生日期：</label>
                            <div class="col-sm-7">
                                <input type="text" name="birthdayDate"  id="birthdayDate"
                                       value="<fmt:formatDate value="${clinicMaster.patMasterIndex.birthdayDate}" pattern="yyyy-MM-dd" type="date" dateStyle="long" />" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control Wdate">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">民族：</label>
                            <div class="col-sm-7">
                                <sys:select checkValue="${clinicMaster.patMasterIndex.nation}" lists="${fns:getDictList('NATION_DICT')}" className="form-control" name="nation"></sys:select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">出生地：</label>
                            <div class="col-sm-7">
                                <input type="text" name="homeplace" value="${clinicMaster.patMasterIndex.homeplace}" class="form-control">
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-5 control-label">性别：</label>
                            <div class="col-sm-7">
                                <%--<label  class="usual_label">${fns:getDictLabels(clinicMaster.patMasterIndex.sex,'SEX_DICT','')}</label>--%>
                                <%--<input type="hidden" name="sex" value="${clinicMaster.patMasterIndex.sex}">--%>
                                <sys:select checkValue="${clinicMaster.patMasterIndex.sex}" lists="${fns:getDictList('SEX_DICT')}" className="form-control" name="sex"></sys:select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">身份证号：</label>
                            <div class="col-sm-7">
                                <input type="text" data-parsley-checkidcard="3"  id="idNo"
                                       maxlength="100" name="idNo" onchange="setIdNo()"
                                       value="${clinicMaster.patMasterIndex.idNo}" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">婚姻：</label>
                            <div class="col-sm-7">
                                <sys:select checkValue="${clinicMaster.patMasterIndex.marriage}" lists="${fns:getDictList('MARRIAGE_DICT')}" className="form-control" name="marriage"></sys:select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">现住址：</label>
                            <div class="col-sm-7">
                                <input type="text" name="address" value="${clinicMaster.patMasterIndex.address}" class="form-control">
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-5 control-label">年龄(岁)：</label>
                            <div class="col-sm-7">
                                <input type="text" name="age" id="age" value="${clinicMaster.patMasterIndex.age}" class="form-control">
                            <%--<label class="usual_label">${clinicMaster.patMasterIndex.age}岁</label>--%>
                                <%--<input type="hidden" name="age" id="age" value="${clinicMaster.patMasterIndex.age}">--%>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">工作单位：</label>
                            <div class="col-sm-7">
                                <input type="text" name="unitInContract" value="${clinicMaster.patMasterIndex.unitInContract}" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">职业：</label>
                            <div class="col-sm-7">
                                <sys:select checkValue="${clinicMaster.patMasterIndex.identity}" lists="${fns:getDictList('PROFESSION_DICT')}" className="form-control" name="occupation"></sys:select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">电话：</label>
                            <div class="col-sm-7">
                                <input type="text" name="phone"  data-parsley-mobilephone="ture"  data-parsley-validate="true" value="${clinicMaster.patMasterIndex.phone}" class="form-control">
                            </div>
                        </div>
                    </div>
                </fieldset>
                <div class="opertion_items">
                    <div>入院信息</div>
                </div>
                <fieldset>
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-5 control-label">入院日期：</label>
                            <input type="hidden" id="dischargeDate" value="${liveRequisition.dischargeDate}" >
                            <div class="col-sm-7">
                                <input type="text" id="hospitalizedDate" data-parsley-required="true"  name="hospitalizedDate" value="<fmt:formatDate value="${liveRequisition.hospitalizedDate}" pattern="yyyy-MM-dd" type="date" dateStyle="long" />" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control Wdate">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">发病日期：</label>
                            <div class="col-sm-7">
                                <input type="text" id="attackdate" data-parsley-required="true"  name="attackdate" value="<fmt:formatDate value="${liveRequisition.attackdate}" pattern="yyyy-MM-dd" type="date" dateStyle="long" />" onclick="WdatePicker({dateFmt:'yyyy-MM-dd',isShowClear:false});" class="form-control Wdate">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">联系人：</label>
                            <div class="col-sm-7">
                                <input type="text" name="contacts" value="${liveRequisition.contacts}"  class="form-control">
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-5 control-label">入院科室：</label>
                            <div class="col-sm-7">
                                <sys:treeselect isnull="true" id="orgDeptId"  name="hospitalizedDept"  value="${liveRequisition.hospitalizedDept}"  update="false" labelName="${liveRequisition.hospitalizedDept}" labelValue="${fns:getDeptName(liveRequisition.hospitalizedDept,'')}"
                                              title="科室" url="/sys/orgDept/treeData?clinicAttrs=0" extId="${orgDept.id}" cssClass="form-control" selectedParent="true" method="isNoFuChanKe"/>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">隔离情况：</label>
                            <div class="col-sm-7">
                                <sys:select checkValue="${liveRequisition.quarantine}" name="quarantine" lists="${fns:getDictList('QUARANTINE_DICT')}" className="form-control" ></sys:select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">关系：</label>
                            <div class="col-sm-7">
                                <sys:select checkValue="${liveRequisition.contactsRelation}" name="contactsRelation" lists="${fns:getDictList('RELATIONSHIP_DICT')}" className="form-control" ></sys:select>
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-5 control-label">入院情况：</label>
                            <div class="col-sm-7">
                                <sys:select checkValue="${liveRequisition.theIllness}" name="theIllness" lists="${fns:getDictList('ADMISSION_SITUATION_DICT')}" className="form-control" ></sys:select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">入院病区：</label>
                            <div class="col-sm-7">
                            <sys:treeselect selectedParent="true" id="wardAdmissionTo" name="wardAdmissionTo"
                                            value="${liveRequisition.wardAdmissionTo}"
                                            update="false"
                                            labelName="${liveRequisition.inDeptWord.id}"
                                            labelValue="${liveRequisition.inDeptWord.deptName}"
                                            title="科室" url="/sys/orgDept/treeData?clinicAttrs=2" isnull="true"
                                            extId="${orgDept.id}" cssClass="form-control" />
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-5 control-label">联系人电话：</label>
                            <div class="col-sm-7">
                                <input type="text"  data-parsley-mobilephone="ture"  data-parsley-validate="true" name="contactsPhone" value="${liveRequisition.contactsPhone}" class="form-control">
                            </div>
                        </div>
                    </div>

                </fieldset>
                <div class="opertion_items">
                    <div>其他信息</div>
                </div>
                <fieldset>
                    <div class="col-lg-8">
                        <div class="form-group">
                            <label class="col-sm-2 control-label">门诊诊断：</label>
                            <div class="col-sm-7">
                                <input type="text" name="diagnosisDesc" value="${hisDiagnosisDes}" readonly="true" class="form-control">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-2 control-label">注意事项：</label>
                            <div class="col-sm-7">
                                <input type="text" name="attention" value="${liveRequisition.attention}"  class="form-control">
                            </div>
                        </div>
                    </div>
                    <div class="col-lg-4">
                        <div class="form-group">
                            <label class="col-sm-5 control-label">建议预交金：</label>
                            <div class="col-sm-7">
                                <input type="number" min="0" value="${liveRequisition.paymentAdvice}" name="paymentAdvice" class="form-control" maxlength="100"
                                       data-parsley-required="true" >
                            </div>
                        </div>
                        </div>
                </fieldset>
            </div>

            <div class="col-lg-1">
                <button id="submit" onclick="isNoDischargeDate()" type="button"  class="btn btn-primary mb5">保存</button>
                <button onclick="printLive('${clinicMaster.id}','')" type="button" class="btn btn-primary">打印</button>
            </div>

        </form>
    </div>
</div>